<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\JsonRpc\CalculatorServiceInterface;
use Hyperf\Context\ApplicationContext;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;

#[Controller]
class CalculatorController extends AbstractController
{
    #[RequestMapping(path: '/sum',methods: ['POST'])]
    public function sum()
    {
        $num1 = $this->request->post('num1', 1);
        $num2 = $this->request->post('num2', 1);
        $client = ApplicationContext::getContainer()->get(CalculatorServiceInterface::class);
        return $client->sum((int)$num1, (int)$num2);

    }

    #[RequestMapping(path: '/sum-pro',methods: ['POST'])]
    public function sumPro()
    {
        $num1 = $this->request->post('num1', 1);
        $num2 = $this->request->post('num2', 1);
        $client = ApplicationContext::getContainer()->get(CalculatorServiceInterface::class);
        return $client->sumPro((int)$num1, (int)$num2);

    }
}
